// pages/index2/index2.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        one: 10,
        current: 1,
        showModalStatus: false,
        animationData: '',
        hiddenName: true,
        flag: false,
        type: "",
        text: "",
        answer: "",
        flag: false,
        data2: [
            {num: 1},



        ]
    },


    choseBtnColor: function (e) {
        var id = e.currentTarget.dataset.id;  //获取自定义的ID值
        console.log(e.currentTarget.dataset.id)
        this.setData({
            one: id
        })
        this.setData({
            showModalStatus: false,
        })
    },

    showModal: function () {
        // 显示遮罩层
        var animation = wx.createAnimation({
            duration: 200,
            timingFunction: "ease-in-out",
            delay: 0
        })
        this.animation = animation
        animation.translateY(500).step()
        this.setData({
            animationData: animation.export(),
            showModalStatus: true
        })
        setTimeout(function () {
            animation.translateY(0).step()
            this.setData({
                animationData: animation.export()
            })
        }.bind(this), 200)
    },
    passr: function () {
        this.setData({
            flag: true
        })
    },
    hideModal: function () {
        this.setData({
            showModalStatus: false,
        })

    },

    click: function (e) {
        this.setData({
            hiddenName: !this.data.hiddenName
        })
    },

    handleChange({detail}) {
        const type = detail.type;
        if (type === 'next') {
            this.setData({
                current: this.data.current + 1
            });
        } else if (type === 'prev') {
            this.setData({
                current: this.data.current - 1
            });
        }
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
      var that = this;
        var pid = options.pid;
        wx.request({
          url: 'http://localhost:8080/eb-back-web/problem/'+pid,//自己的服务接口地址
          method: 'post',
          header: {
            'content-type': 'application/x-www-form-urlencoded'
          },
          data: { pid: pid },
          success: function (res) {
            console.log(res.data.subject);
            that.setData({
                text:res.data.text,
                answer:res.data.answer,
                type:res.data.type

            });

          },
          fail: function () {
            console.log('系统错误')
          }
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})
